<?php

	require "configs/smartmain.php"; 
	session_start();
	$dbName=$_REQUEST["databaseName"];
	if($dbName==null){
		echo "error <br>";
	}
	else{
		//echo "user select ".$dbName." <br>";
		$_SESSION ['DB_DATABASE']=$dbName;
	}
	require "configs/Mysql.class.php";
	
	$db=new DB;
	$query=$db->query("show tables");
	$databaseNames = array();
		//echo "start <p>";
	for ($counter=0;;$counter++)
	{
		$row = $db->fetch_array($query);
		if(!$row){
			break;
		}
		
		$databaseNames[$counter]=$row["Tables_in_".$dbName];
		//echo $counter."=".$databaseNames[$counter]."<br>";

	}
	
	$db->close();
	
	$template->assign("Message","Hello Word!");
	$template->assign("TableNames",$databaseNames);
	$template->assign("tableSize",count($databaseNames));
	

	$template->display('select_tables.tpl.html');
	
	
?>
